package com.aioz.security.controller;


import com.aioz.security.aop.annotation.LogInfoAnnotation;
import com.aioz.security.common.ResponseResult;
import com.aioz.security.service.impl.FileServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Aioz
 * @since 2022-09-28
 */
@RestController
@RequestMapping("/file")
public class FileController {

    @Autowired
    private FileServiceImpl fileService;

    //上传简历文件
    // market-1312547758.cos.ap-beijing.myqcloud.com
    @PostMapping("/resume/upload")
    @LogInfoAnnotation
    public ResponseResult uploadResume(MultipartFile file){
        return fileService.uploadResume(file);
    }

    //用户上传头像
    @PostMapping("/user/avatar/upload")
    @LogInfoAnnotation
    public ResponseResult uploadUserAvatar(MultipartFile file){
        return fileService.uploadUserAvatar(file);
    }

    // 上传企业照片
    @PostMapping("/company/photos/{name}")
    @LogInfoAnnotation
    public ResponseResult uploadCompanyPhotos(MultipartFile file,
                                              @PathVariable String name){
        return fileService.uploadCompanyPhotos(file,name);
    }



    //根据企业ID查询企业图片
    @PostMapping("/get/photos/{companyId}")
    @LogInfoAnnotation
    public ResponseResult getPhotosByCompanyId(@PathVariable Integer companyId){
        return fileService.getPhotosByCompanyId(companyId);
    }

}
